<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Add Classroom</title>
</head>

<body>

<?php
//get num_rows currently in buildings table
$classroom_id = $_GET['id'];
$building_id = $_GET['bid'];
$building_name = $_GET['name'];
$abbreviation = $_GET['abbrev'];

echo "<h1>UNO Course Scheduler - Add Classroom in $building_name</h1>";

//initialize variables used to connect to database
$db = "scheduler";
$user = "root";
$pass = "";

//counting variable
$i = 0;

//connect to database
mysql_connect("localhost", $user, $pass);
@mysql_select_db($db);

$query="SELECT * FROM classroom_types";
$result=mysql_query($query);

//determine dynamically number of rows read from table
$num_rows=mysql_numrows($result);

//close
mysql_close();

echo '<p>';

$classroom_type_id = 1;

echo '<form action="add_do.php" method="get">';

//start table
echo "<table border='0'>";
	
	//create table row
	echo "<tr>";
		echo "<td><b>Room Number</b></td>";
		echo '<td><input type="text" name="room_num"></td>';
	echo "</tr>";
	
	//create table row
	echo "<tr>";
		echo "<td><b>Seating Capacity</b></td>";
		echo '<td><input type="text" name="num_seats"></td>';
	echo "</tr>";
	
	echo "<tr>";
		echo "<td><b>Classroom Type</b></td>";
		echo "<td>";
			echo "<select name='type'>";
				while ($i < $num_rows)
				{
					$type_description=mysql_result($result,$i,"description");
					echo "<option>$type_description</option>";
					$i++;
				}
			echo "</select>";
	echo "</tr>";


//end table tag
echo "</table>";

echo "<input type='hidden' name='id' value='$classroom_id'>";
echo "<input type='hidden' name='bid' value='$building_id'>";
echo "<input type='hidden' name='name' value='$building_name'>";
echo "<input type='hidden' name='abbrev' value='$abbreviation'>";
echo '<input type="submit">';
echo '</form>';

echo "<p>";
	echo "<a href='index.php?id=$building_id&name=$building_name&abbrev=$abbreviation'>&lt;&lt; Back to Classrooms Portal</a><br />";
echo "</p>";

?>

</body>
</html>